package com.gxa.controller.statistics;

import com.gxa.common.R;
import com.gxa.entity.DistrictSysNews;
import com.gxa.service.NewsService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@Api(value = "消息中心",tags = "消息中心接口API")
@RequestMapping("/district_sys_news")
public class NewsController {
    @Autowired
    private NewsService newsService;

    /**
     * 分页查询所有消息
     * @param currentPage
     * @param pageSize
     * @return
     */
    @RequestMapping(value = "/findnews",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "查询所有消息接口",notes = "查询所有消息",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页数据条数",paramType = "query",dataType = "int",required = true)
    })
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findnews(Integer currentPage,Integer pageSize) {

        return newsService.findnews(currentPage,pageSize);
    }


    /**
     * 根据消息类型，创建日期，消息状态查询消息
     * @param currentPage
     * @param pageSize
     * @param newsType
     * @param createDate
     * @param newsStatus
     * @return
     */
    @RequestMapping(value = "/findnewsbyconditions",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "根据条件查询消息接口",notes = "根据条件查询消息",httpMethod = "POST", response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页数据条数",required = true,paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "newsType",value = "消息类型",required = false,paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "newsStatus",value = "消息状态",required = false,paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "createDate",value = "创建时间",required = false,paramType = "query",dataType = "int")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R findnewsbyconditions( Integer currentPage, Integer pageSize, String newsType , Date createDate , Integer newsStatus){

        return newsService.findnewsbyconditions(currentPage,pageSize,newsType,createDate,newsStatus);
    }

    /**
     * 所有消息全部标记为已读
     * @return
     */
    @RequestMapping(value = "/allmarkasread",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "全部标记为已读接口",notes = "全部标记为已读",httpMethod = "POST", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="查询成功"),
            @ApiResponse(code=401,message="token为空"),
            @ApiResponse(code=1005,message="Token过期"),
            @ApiResponse(code=1006,message="Token验证不通过"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R allmarkasread( ){

        return newsService.allmarkasread();
    }


}
